﻿@model AutoPartsSearch.Web.Areas.Administration.Models.BlackList.ViewModel
@using AutoPartsSearch.Web.HtmlHelpers
@{
    ViewBag.Title = "List";
    Layout = "~/Areas/Administration/Views/_Layout.cshtml";
}

<h2>Список блэк-лист</h2>
<fieldset>
    
    <table class="table-form">
        <thead>
            <tr>
                <th></th>
                <th>Id</th>
                <th>Компания</th>
                <th>Пользователь</th>
                <th>Телефон</th>
                <th>EMail</th>
                <th>Комментарий</th>
                <th>Проверен</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var blackList in Model.BlackLists)
            {
                <tr>
                    <td>
                        @Html.ActionLink("Детали", "Details", new { id = blackList.Id }, new { @class = "editButton" })
                    </td>
                    <td>@blackList.Id</td>
                    <td>@blackList.Seller.CompanyName</td>
                    <td>@blackList.Name</td>
                    <td>@blackList.Phone</td>
                    <td>@blackList.EMail</td>
                    <td>@(blackList.Comments.Length > 30 ? blackList.Comments.Substring(0, 30) + " ..." : blackList.Comments)</td>
                    <td>@(blackList.IsApproved ? "Да" : "Нет")</td>
                    <td>
                        @using (Html.BeginForm("Update", "BlackList", new {Id = blackList.Id, IsApproved = !blackList.IsApproved, Comments = blackList.Comments}))
                        {
                            if (!blackList.IsApproved)
                            {
                                <input type="submit" value="Подтвердить"/>
                            }
                            else
                            {
                                <input type="submit" value="Отменить подтверждение"/>
                            }

                        }
                    </td>
                </tr>
            }
        </tbody>
        <tfoot>
            <tr>
                <td colspan="9">
                    @Html.PageLinks(Model.PagingInfo, x => Url.Action("List", "BlackList", new {page = x}))
                </td>
            </tr>
        </tfoot>
    </table>
    
</fieldset>